package com.leetcode.algorithm.y22.m09.w2;

/**
 * 2224. 转化时间需要的最少操作数
 * 
 * https://leetcode.cn/problems/minimum-number-of-operations-to-convert-time/
 * 
 * @author jie.deng
 *
 */
class Question2224Solution01 {

	public int convertTime(String current, String correct) {
		String[] currentArr = current.split(":");
		String[] correctArr = correct.split(":");
		int currentH = currentArr[0].charAt(0) == '0' ? Integer.parseInt("" + currentArr[0].charAt(1))
				: Integer.parseInt(currentArr[0]);
		int currentM = Integer.parseInt(currentArr[1]);
		int correctH = correctArr[0].charAt(0) == '0' ? Integer.parseInt("" + correctArr[0].charAt(1))
				: Integer.parseInt(correctArr[0]);
		int correctM = Integer.parseInt(correctArr[1]);
		if (correctM < currentM) {
			correctM += 60;
			correctH--;
		}
		int cnt = correctH - currentH;
		int diff = correctM - currentM;
		cnt += diff / 15;
		diff = diff % 15;
		cnt += diff / 5;
		diff = diff % 5;
		cnt += diff;
		return cnt;
	}

}